beginoutdoorscript;

variables;

body;

beginstate 0; //INIT_STATE
break;

beginstate 1; //EXIT_STATE
break;

beginstate 2; //START_STATE

	//changing the terrain around... ships and such
	// (only necessary if you haven't made them all move)
	if(get_flag(52,1) != 3) {
	//Reset flags for outdoor terrain changes
	if((get_terrain(28,42) == 487) && (get_flag(52,3) == 1)) //ships
		set_flag(52,3,0);
		
	//terrain changes
	if((get_flag(52,3) == 0) && (get_flag(3,0) == 1)) {
		//blew up watchtower, move ships near island
		if(get_flag(4,2) == 3) {
			//erase old ship terrains
			set_terrain(26,39,0);
			set_terrain(26,40,0);
			set_terrain(28,42,0);
			set_terrain(29,42,0);
			set_terrain(30,40,0);
			set_terrain(30,41,0);
			//"move" them over to the island
			set_terrain(23,14,485);
			set_terrain(23,15,486);
			set_terrain(29,22,487);
			set_terrain(30,22,488);
			set_terrain(32,24,485);
			set_terrain(32,25,486);
			set_flag(52,3,1);
			end();
			}
		}
		}
	
	//get rid of the ships
	if((get_flag(52,1) == 3) && ((get_terrain(30,40) == 489) || (get_terrain(23,14) == 485))) {
		//nuke all possible places the ships could be
		set_terrain(26,39,0);
		set_terrain(26,40,0);
		set_terrain(28,42,0);
		set_terrain(29,42,0);
		set_terrain(30,40,0);
		set_terrain(30,41,0);
		
		set_terrain(23,14,0);
		set_terrain(23,15,0);
		set_terrain(29,22,0);
		set_terrain(30,22,0);
		set_terrain(32,24,0);
		set_terrain(32,25,0);
		}
break;

beginstate 10; //sand runes
	if(get_flag(52,5) == 1)
		end();
	if(has_item(445) == 0)
		end();

	reset_dialog();
	add_dialog_str(0,"The key you got from the crazy hermit starts vibrating in your pack, and you feel like someone is watching you for a moment. Fortunately, the feeling passes.",0);
	run_dialog(1);
	
	award_party_xp(100,10);
	
	set_flag(52,5,1);
break;

beginstate 15; //moving east
	if(get_flag(52,0) == 1)
		end();
	reset_dialog();
	add_dialog_str(0,"You keep paddling east, occasionally stopping to bail out the boat.",0);
	add_dialog_str(1,"Vantanas hasn't been settled that much yet, at least compared to the other continents. The mainland is primarily settled at the coasts, and the surrounding islands haven't even been fully charted yet.",0);
	add_dialog_str(2,"In some of the more remote chains of islands, it's possible to sail for days without seeing a settlement. But here, not so much.",0);
	add_dialog_str(3,"All the more strange that an open rebellion would strike here... why not pick somewhere without as much Empire influence?",0);
	run_dialog(1);
	message_dialog("You notice a few ships off to the south, floating idle. Something seems strange about them, but you can't immediately put your finger on it...","");
	set_flag(52,0,1);
break;

beginstate 20; //DL ships!
	if(get_flag(52,1) >= 1)
		end();
	reset_dialog();
	add_dialog_str(0,"As you get closer to the ships, it finally hits you. These aren't Empire ships. They aren't trader ships either.",0);
	run_dialog(1);
	reset_dialog();
	add_dialog_str(0,"That's not good. If these are really Darkside Loyalist ships, then you can be sure of a few things. First, there are a lot of Loyalists around.",0);
	add_dialog_str(1,"Second, they are probably well-equipped if they can afford ships. And third, well... they probably won't be letting you through.",0);
	add_dialog_str(2,"Your best shot at getting past is probably to distract the Loyalists, drawing their attention (and ships) elsewhere. The question is how to do that...",0);
	run_dialog(1);
	set_flag(52,1,1);
break;

beginstate 21; //don't charge at the ships
	if(get_flag(52,1) != 1)
		end();
	message_dialog("Charging directly at the Loyalist ships, while perhaps brave in some circles, is probably suicidal.","You turn back.");
	block_entry(1);
break;

beginstate 22; //don't charge at the ships (after moving them)
	if(get_flag(52,1) != 2)
		end();
	message_dialog("Charging directly at the Loyalist ships, while perhaps brave in some circles, is probably suicidal. Particularly after going to such great lengths to distract them in the first place.","You turn back.");
	block_entry(1);
break;

beginstate 25; //noticing the watchtower
	if(get_flag(52,2) == 1) {
		if(get_flag(4,2) == 3) {
			message_dialog("Hm... if burning down the watchtower was meant to distract the Loyalists, maybe you shouldn't hang around the scene of the crime.","");
			block_entry(1);
			}
		end();
		}
	reset_dialog();
	add_dialog_str(0,"As you approach the watchtower that watches over these islands, something doesn't seem right. That nagging feeling is confirmed when you trip over the corpse of an Empire soldier.",0);
	add_dialog_str(1,"You can see figures gathered around a fire outside the watchtower, but you can't make out any faces from here. It's probably a safe bet that they won't be too happy to see you, though.",0);
	run_dialog(1);
	set_flag(52,2,1);
break;

beginstate 30; //slip past the ships
	if((get_flag(52,1) != 2) || (get_flag(52,4) == 1))
		end();
	reset_dialog();
	add_dialog_str(0,"You slip past the Darkside ships, though 'slip' might not be the right word. You don't believe for a second that they haven't spotted you. All that matters is that they don't chase after you.",0);
	add_dialog_str(1,"Fortunately, they don't seem to be moving. You are safe for now.",0);
	run_dialog(1);
	set_flag(52,4,1);
break;